#include "head.h"

// 长命令封装小火车
int make_protocal(messenger_t *msg, const cmd_t cmd, const me_t *me, const char *cmds)
{
    msg->cmd = cmd;
    while(*cmds++ != ' ');
    sprintf(msg->args, "%s&%s", me->path, cmds);
    sprintf(msg->token, "%s", me->token);
    return 0;
}

// 子线程的入口函数
void* start_routine(void* arg)
{
    messenger_t* msg = (messenger_t*)arg;

    // 创建新连接
    int sock_fd = 0;
    tcp(&sock_fd);
    printf("sock_fd = %d\n", sock_fd);
    
    // send(sock_fd, &msg, sizeof(msg), MSG_NOSIGNAL);
    // printf("args = %s token = %s\n", msg->args, msg->token);
    switch(msg->cmd)
    {
    case UP: up(msg, sock_fd);   break;
    }


    printf("子线程退出\n");
    // 接收返回信息


}